home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-11-13 | 7.1 KB | 194 lines | [TEXT/R*ch] |
- // ===========================================================================
- // File: CMPDIncludeView.cp
- // Version: 1.0 - Feb 1, 1996
- // Author: Mike Shields (mshields@inconnect.com)
- //
- // Copyright ©1996 Mike Shields. All rights reserved.
- // I hereby grant users of CMPDIncludeView permission to use it (or any modified
- // version of it) in applications (or any other type of Macintosh software
- // like extensions -- freeware, shareware, commercial, or other) for free,
- // subject to the terms that:
- //
- // (1) This agreement is non-exclusive.
- //
- // (2) I, Mike Shields, retain the copyright to the original source code.
- //
- // These two items are the only required conditions for use. However, I do have
- // an additional request. Note, however, that this is only a request, and
- // that it is not a required condition for use of this code.
- //
- // (1) That I be given credit for CMPDIncludeView code in the copyrights or
- // acknowledgements section of your manual or other appropriate documentation.
- //
- //
- // I would like to repeat that this last item is only a request. You are prefectly
- // free to choose not to do any or all of them.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // ===========================================================================
- // CMPDIncludeView.h <- double-click + Command-D to see class declaration
- //
- // Class which controls the loading and disposing of a panel subpane in a
- // multi-pane dialog.
- // Also handles the relationship of getting and setting the data represented by
- // that particular panel
-
- #include "CMPDIncludeView.h"
- #include "CMPDPanel.h"
-
- #include <PP_Constants.h>
-
- #pragma mark === Construction & Destruction ===
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::CreateFromStream
- //----------------------------------------------------------------------------------------
- // Static function registered with URegistrar to create a MPDIncludeView from the data
- // in a stream
- CMPDIncludeView* CMPDIncludeView::CreateFromStream(LStream *inStream)
- {
- return (new CMPDIncludeView(inStream));
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::CMPDIncludeView
- //----------------------------------------------------------------------------------------
- // Default constructor
- CMPDIncludeView::CMPDIncludeView()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::CMPDIncludeView
- //----------------------------------------------------------------------------------------
- // Create form th data in the stream
- CMPDIncludeView::CMPDIncludeView(LStream *inStream)
- : CIncludeView(inStream)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::~CMPDIncludeView
- //----------------------------------------------------------------------------------------
- // Destructor
- CMPDIncludeView::~CMPDIncludeView()
- {
- }
-
- #pragma mark === Panel Management ===
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::LoadNewMPDPanel
- //----------------------------------------------------------------------------------------
- // Load in a new MPD panel and set the data for it. As we do this we'll get the
- // data from the last panel included in this view and return that data.
- void CMPDIncludeView::LoadNewMPDPanel(ResIDT inPanelID, Handle inNewPanelData,
- Handle inOldPanelData, Boolean inRefresh)
- {
- if ( mPaneID != PaneIDT_Undefined )
- {
- // get the data from the current MPD panel
- GetPanelData(inOldPanelData);
- }
-
- // install the new view.
- IncludeView(inPanelID, false);
-
- if ( mPaneID != PaneIDT_Undefined )
- {
- // and set the MPD data into the new panel
- UseNewPanelData(inNewPanelData, false);
-
- // force the included pane to be redrawn. This works better than just refreshing the pane.
- if ( inRefresh )
- {
- Refresh();
- }
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::UseNewPanelData
- //----------------------------------------------------------------------------------------
- // Tell the included panel that it needs to display new data.
- void CMPDIncludeView::UseNewPanelData(Handle inNewPanelData, Boolean inRefresh)
- {
- SignalIf_(inNewPanelData == nil);
- CMPDPanel* aPanel = dynamic_cast<CMPDPanel*>(mCurrentIncludedPane);
- SignalIf_(aPanel == nil );
-
- // Setting the ClipRgn to nil will prevent the LStdControl based controls from drawing
- // as the SetData call updates the state of the controls to reflect the current data.
- StClipRgnState saveClip(nil);
-
- if ( aPanel != nil )
- {
- aPanel->SetData(inNewPanelData);
- }
-
- if ( inRefresh )
- Refresh();
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::GetPanelData
- //----------------------------------------------------------------------------------------
- // ask the included panel for the data it currently contains.
- void CMPDIncludeView::GetPanelData(Handle inDataToReplace)
- {
- SignalIf_(inDataToReplace == nil);
- CMPDPanel* aPanel = dynamic_cast<CMPDPanel*>(mCurrentIncludedPane);
- SignalIf_(aPanel == nil );
- if ( aPanel != nil )
- {
- // return the data contained in the current panel
- aPanel->GetData(inDataToReplace);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::ValidatePanel
- //----------------------------------------------------------------------------------------
- // ask the contained panel to validate its contents.
- // Return TRUE if data is valid, FALSE if not
- Boolean CMPDIncludeView::ValidatePanel(void)
- {
- CMPDPanel* aPanel = dynamic_cast<CMPDPanel*>(mCurrentIncludedPane);
- SignalIf_(aPanel == nil );
- if ( aPanel != nil )
- return aPanel->ValidatePanel();
- else
- return true;
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::WantDefaultsButton
- //----------------------------------------------------------------------------------------
- // ask the contained panel if it needs/wants the Use Defaults Button.
- // Return TRUE if it does, FALSE if not
- Boolean CMPDIncludeView::WantDefaultsButton(void)
- {
- CMPDPanel* aPanel = dynamic_cast<CMPDPanel*>(mCurrentIncludedPane);
- SignalIf_(aPanel == nil );
- if ( aPanel != nil )
- return aPanel->WantDefaultsButton();
- else
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // CMPDIncludeView::WantRevertButton
- //----------------------------------------------------------------------------------------
- // ask the contained panel if it needs/wants the Revert Button.
- // Return TRUE if it does, FALSE if not
- Boolean CMPDIncludeView::WantRevertButton(void)
- {
- CMPDPanel* aPanel = dynamic_cast<CMPDPanel*>(mCurrentIncludedPane);
- SignalIf_(aPanel == nil );
- if ( aPanel != nil )
- return aPanel->WantRevertButton();
- else
- return false;
- }
-